/*     */ package com.infoservice.schedule.generator;
/*     */ 
/*     */ import com.infoservice.schedule.Constant;
/*     */ import com.infoservice.schedule.po.pos.TaskPO;
/*     */ import com.infoservice.schedule.util.TaskUtils;
/*     */ import java.util.Calendar;
/*     */ import java.util.Date;
/*     */ 
/*     */ public class GenDayTask extends TaskGenerator
/*     */ {
/*     */   public GenDayTask(TaskPlanInfo tpInfo, TaskPO tk)
/*     */   {
/*  35 */     super(tpInfo, tk);
/*     */   }
/*     */ 
/*     */   public long getDelayTime()
/*     */   {
/*  43 */     Date nextTime = getNextExcTime();
/*  44 */     Calendar cur = TaskUtils.getCalendar();
/*  45 */     return nextTime.getTime() - cur.getTimeInMillis() < Constant.TASK_GEN_AHEAD_TIME ? 0L : nextTime.getTime() - cur.getTimeInMillis() - Constant.TASK_GEN_AHEAD_TIME;
/*     */   }
/*     */ 
/*     */   public long getPeriodTime()
/*     */   {
/*  53 */     return 86400000L;
/*     */   }
/*     */ 
/*     */   public void run()
/*     */   {
/*  61 */     genTask();
/*     */   }
/*     */ 
/*     */   public Date getNextExcTime()
/*     */   {
/*  69 */     Calendar cur = TaskUtils.getCalendar();
/*  70 */     Date planStartTime = null;
/*  71 */     if (this.tk == null) {
/*  72 */       Calendar start = TaskUtils.getCalendar();
/*  73 */       String[] temp = this.tpInfo.getPlanStart().split(":");
/*  74 */       start.set(11, Integer.parseInt(temp[0]));
/*  75 */       start.set(12, Integer.parseInt(temp[1]));
/*  76 */       planStartTime = start.getTime();
/*  77 */       if (planStartTime.getTime() >= cur.getTimeInMillis())
/*  78 */         return planStartTime;
/*     */     } else {
/*  80 */       planStartTime = this.tk.getPlanStartTime();
/*  81 */       if (planStartTime.getTime() >= cur.getTimeInMillis())
/*  82 */         return new Date(planStartTime.getTime() + getInterval());
/*     */     }
/*  84 */     long times = (cur.getTimeInMillis() - planStartTime.getTime()) / 86400000L;
/*  85 */     times += 1L;
/*  86 */     return new Date(planStartTime.getTime() + 86400000L * times);
/*     */   }
/*     */ 
/*     */   public int getIgnoreTimes()
/*     */   {
/*  93 */     Calendar cur = TaskUtils.getCalendar();
/*  94 */     Date planStartTime = null;
/*  95 */     if (this.tk == null) {
/*  96 */       Calendar start = TaskUtils.getCalendar();
/*  97 */       String[] temp = this.tpInfo.getPlanStart().split(":");
/*  98 */       start.set(11, Integer.parseInt(temp[0]));
/*  99 */       start.set(12, Integer.parseInt(temp[1]));
/* 100 */       planStartTime = start.getTime();
/* 101 */       if (cur.getTimeInMillis() < planStartTime.getTime()) {
/* 102 */         return 0;
/*     */       }
/* 104 */       long times = (cur.getTimeInMillis() - planStartTime.getTime()) / getInterval();
/* 105 */       return (int)times + 1;
/*     */     }
/*     */ 
/* 108 */     planStartTime = this.tk.getPlanStartTime();
/* 109 */     if (cur.getTimeInMillis() < planStartTime.getTime()) {
/* 110 */       return 0;
/*     */     }
/* 112 */     long times = (cur.getTimeInMillis() - planStartTime.getTime()) / getInterval();
/* 113 */     return (int)times;
/*     */   }
/*     */ 
/*     */   public void removeTaskPlan()
/*     */   {
/* 122 */     cancel();
/*     */   }
/*     */ 
/*     */   public void setTaskPO(Date planStartTime)
/*     */   {
/* 130 */     if (this.tk == null) {
/* 131 */       this.tk = new TaskPO();
/*     */     }
/* 133 */     this.tk.setPlanStartTime(planStartTime);
/*     */   }
/*     */ 
/*     */   public Date getEndDate()
/*     */   {
/* 142 */     String[] end = this.tpInfo.getPlanEnd().split(":");
/* 143 */     Calendar cur = TaskUtils.getCalendar();
/* 144 */     cur.set(11, Integer.parseInt(end[0]));
/* 145 */     cur.set(12, Integer.parseInt(end[1]));
/* 146 */     return cur.getTime();
/*     */   }
/*     */ 
/*     */   public Date getStartDate()
/*     */   {
/* 153 */     String[] end = this.tpInfo.getPlanStart().split(":");
/* 154 */     Calendar cur = TaskUtils.getCalendar();
/* 155 */     cur.set(11, Integer.parseInt(end[0]));
/* 156 */     cur.set(12, Integer.parseInt(end[1]));
/* 157 */     return cur.getTime();
/*     */   }
/*     */ 
/*     */   public long getInterval()
/*     */   {
/* 164 */     return 86400000L;
/*     */   }
/*     */ }

/* Location:           D:\Workspace\Work\ASMP_DE\lib\frame3\InfoSchedule_1.0.03.jar
 * Qualified Name:     com.infoservice.schedule.generator.GenDayTask
 * JD-Core Version:    0.6.0
 */